package com.winning.devops.batch.reader.ch02.writer;

import com.winning.devops.batch.reader.ch02.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemWriter;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author chensj
 * @date 2020-02-29 22:00
 */
@Component("databaseJdbcDemoItemWriter")
public class DatabaseJdbcDemoItemWriter implements ItemWriter<User> {

    /**
     * logger
     */
    private static final Logger logger = LoggerFactory.getLogger(DatabaseJdbcDemoItemWriter.class);

    @Override
    public void write(List<? extends User> list) throws Exception {
        if (list.size() > 0) {
            for (User user : list) {
                logger.info("User {}", user);
            }
        }

    }
}
